// ******************************************************************
// * Copyright(c)  Steven Lu
// * Description   : Entity_PROD_WO_PICK
// * CreateDate    : 2014-01-01 14:50:36
// * Creater       : CodeSmith
// * LastChangeDate: 2014-01-01 14:50:36
// * LastChanger   : 2014-01-01 14:50:36
// * Version Info  : 1.0 For ESOL
// ******************************************************************

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Suzsoft.Smart.Data;
using ESOL.Common.Entity;

namespace ESOL.Business.Prod
{
/// <summary>
    /// ProdWoPick
    /// </summary>
    public partial class ProdWoPickBs
    {
        #region GetByID
        /// <summary>
        /// Get Entity
        /// </summary>
        /// <param name="objProdWoPickEntity">Entity</param>
        /// <returns>Entity</returns>
        public static ProdWoPickEntity GetProdWoPick(ProdWoPickEntity objProdWoPickEntity)
        {
            return DataAccess.SelectSingle<ProdWoPickEntity>(objProdWoPickEntity);
        }
        #endregion


        #region Insert
        /// <summary>
        /// Insert Data
        /// </summary>
        /// <param name="objProdWoPickEntity">Entity</param>
        /// <returns>true Insert Succeed; false Insert Fail</returns>
        public static bool InsertProdWoPick(ProdWoPickEntity objProdWoPickEntity)
        {
            return DataAccess.Insert(objProdWoPickEntity);
        }

        public static bool InsertProdWoPick(List<ProdWoPickEntity> objProdWoPickEntityList)
        {
            return DataAccess.Insert(objProdWoPickEntityList);
        }
        #endregion


        #region Update
        /// <summary>
        /// Update Data
        /// </summary>
        /// <param name="objProdWoPickEntity">Entity</param>
        /// <returns>true Update Succeed; false Update Fail</returns>
        public static bool UpdateProdWoPick(ProdWoPickEntity objProdWoPickEntity)
        {
            return DataAccess.Update(objProdWoPickEntity);
        }

        public static bool UpdateProdWoPick(List<ProdWoPickEntity> objProdWoPickEntityList)
        {
            return DataAccess.Update<ProdWoPickEntity>(objProdWoPickEntityList);
        }
        #endregion


        #region Delete
        /// <summary>
        /// Delete Data
        /// </summary>
        /// <param name="objProdWoPickEntity">Entity</param>
        /// <returns>true Delete Succeed; false Delete Fail</returns>
        public static bool DeleteProdWoPick(ProdWoPickEntity objProdWoPickEntity)
        {
            return DataAccess.Delete(objProdWoPickEntity);
        }

        public static bool DeleteProdWoPick(List<ProdWoPickEntity> objProdWoPickEntityList)
        {
            return DataAccess.Delete<ProdWoPickEntity>(objProdWoPickEntityList);
        }
        #endregion


        #region GetAll
        /// <summary>
        /// Get All Data
        /// </summary>
        /// <returns>Back All Data<returns>
        public static DataSet GetProdWoPickAll()
        {
            return DataAccess.SelectAllDataSet<ProdWoPickEntity>();
        }
        /// <summary>
        /// Get All Data List
        /// </summary>
        /// <returns>Back All Data List<returns>
        public static List<ProdWoPickEntity> GetProdWoPickAllList()
        {
            return DataAccess.SelectAll<ProdWoPickEntity>();
        }
        #endregion

        public static bool CreateWoPick(ProdWoPickEntity pick, List<ProdWoPickitemEntity> pickItems)
        {
            using (DataAccessBroker broker = DataAccessFactory.Instance())
            {
                try
                {
                    broker.BeginTransaction();
                    DataAccess.Insert(pick, broker);
                    DataAccess.Insert<ProdWoPickitemEntity>(pickItems, broker);
                    broker.Commit();
                    return true;
                }
                catch (Exception ex)
                {
                    broker.RollBack();
                    throw ex;
                }
            }
        }

        //public static bool Pick(ProdWoPickEntity pick,List<ProdWoTaskEntity> woTasks,List<ProdWoReportEntity> woReports)
        //{
        //    using (DataAccessBroker broker = DataAccessFactory.Instance())
        //    {
        //        try
        //        {
        //            broker.BeginTransaction();
        //            DataAccess.Update(pick, broker);
        //            DataAccess.Update<ProdWoTaskEntity>(woTasks, broker);
        //            DataAccess.Insert<ProdWoReportEntity>(woReports, broker);
        //            broker.Commit();
        //            return true;
        //        }
        //        catch (Exception ex)
        //        {
        //            broker.RollBack();
        //            throw ex;
        //        }
        //    }
        //}
	}
	
	
}	

